package com.gitee.wsl.compose.modifier.state

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp


/**
 * Once this applied, when you hover the mouse over the item, it's background color will be changed.
 */
//@OptIn(ExperimentalComposeUiApi::class)
//@Composable
//fun Modifier.addHoverEffect(
//    onClicked: () -> Unit,
//    normalColor: Color = MaterialTheme.colorScheme.secondary,
//    normalAlpha: Float = 0f,
//    hoverAlpha: Float = 0.8f,
//    cornerRadius: Dp = 5.dp
//): Modifier {
//    var isHovered by remember { mutableStateOf(false) }
//    val backgroundAlpha = if (isHovered) {
//        hoverAlpha
//    } else {
//        normalAlpha
//    }
//
//    return this.background(
//        normalColor.copy(alpha = backgroundAlpha),
//        RoundedCornerShape(cornerRadius)
//    ).clickable {
//        onClicked()
//    }.onPointerEvent(eventType = PointerEventType.Enter, onEvent = {
//        isHovered = true
//    }).onPointerEvent(eventType = PointerEventType.Exit, onEvent = {
//        isHovered = false
//    })
//}